$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('mata[name="csrf-token"]').attr('content')
    }
});



var editor = new wangEditor("content");
editor.config.uploadImgUrl = 'posts/image/upload';
//设置header
editor.config.uploadHeaders = {
    'X-CSRF-TOKEN': $('mata[name="csrf-token"]').attr('content')
}
editor.create();


$(".like-button").click(function (event) {
    var target = $(event.target);
    var current_like = target.attr("like-value");
    var user_id = target.attr("like-value");
    if (current_like == 1) {
        //取消关注
        $.ajax({
            url: "user/" + user_id + "/unfan",
            method:"post",
            dataType:"json",
            success:function () {
                if (data.error != 0){
                    alert(data.msg);
                    return;
                }
                target.attr('like-value',0);
                target.text('关注');
            }

        })

    }else{
        //关注
        $.ajax({
            url: "user/" + user_id + "/fan",
            method:"post",
            dataType:"json",
            success:function () {
                if (data.error != 0){
                    alert(data.msg);
                    return;
                }
                target.attr('like-value',0);
                target.text('取消关注');
            }

        })
    }

})